// pages/all_plan/all_plan.js
var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    tablist:["全部","待开启","进行中","已中止"],
    tabIndex:0,
    page:0,
    j_id:"",
    status:0,
    pagesize:10,
    list:[],
  },
  // tab切换
  bindtab(e){
    this.setData({
      tabIndex:e.target.dataset.index,
      status:e.target.dataset.index,
      page:0,
      list:[],
      j_id:"",
    })
    this.getList();
  },
  // 随访详情
  binddetail(e){
    wx.navigateTo({
      url: '/hyb_yl/huanzhe/pages/plan_detail/plan_detail?id='+e.currentTarget.dataset.id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var j_id = options.j_id;
    if(j_id != '' && j_id != undefined && j_id != 'undefined')
    {
      that.setData({
        j_id:j_id
      })
    }
    
    that.getList();
  },
  getList:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/follow.user_follow",
      data:{
        openid:wx.getStorageSync("openid"),
        j_id:that.data.j_id,
        page:that.data.page,
        status:that.data.status,
        pagesize:that.data.pagesize
      },
      success:function(res)
      {
        that.setData({
          list:that.data.list.concat(res.data),
          page:that.data.page + 1
        })
      }
    })
  },
  onReachBottom: function () {
    this.getList();
  },
})